<template>
  <div class="body">
    <el-button type="primary" @click="print()" class="add_btn">打印工单</el-button>
    <el-table
      :data="ChildList"
      v-loading="loading"
      style="width: 100%"
      @selection-change="handleSelectionChang"
      header-cell-class-name="header_style"
      border
    >
    <el-table-column
          type="selection"
          width="55">
        </el-table-column>
      <el-table-column  label="客户名称"> 
        <template slot-scope="scope">
          <div>
            <p v-for="(item,index) in scope.row" :key="index">
              <span v-if="item.field_name=='客户名称'">{{item.value}}</span>
            </p>
          </div>
        </template>
      </el-table-column>

      <el-table-column  label="产品名称"> 
        <template slot-scope="scope">
          <div>
            <p v-for="(item,index) in scope.row" :key="index">
              <span v-if="item.field_name=='产品名称'">{{item.value}}</span>
            </p>
          </div> 
        </template>
      </el-table-column>
      
      <el-table-column  label="订单号"> 
        <template slot-scope="scope">
          <div>
            <p v-for="(item,index) in scope.row" :key="index">
              <span v-if="item.field_name=='订单号'">{{item.value}}</span>
            </p>
          </div> 
        </template>
      </el-table-column>
      <el-table-column  label="订单型号"> 
        <template slot-scope="scope">
          <div>
            <p v-for="(item,index) in scope.row" :key="index">
              <span v-if="item.field_name=='订单型号'">{{item.value}}</span>
            </p>
          </div> 
        </template>
      </el-table-column>
      <el-table-column  label="领单人"> 
        <template slot-scope="scope">
          <div>
            <p v-for="(item,index) in scope.row" :key="index">
              <span v-if="item.field_name=='领单人'">{{item.value}}</span>
            </p>
          </div> 
        </template>
      </el-table-column>
      <el-table-column  label="职工工种"> 
        <template slot-scope="scope">
          <div>
            <p v-for="(item,index) in scope.row" :key="index">
              <span v-if="item.field_name=='职工工种'">{{item.value}}</span>
            </p>
          </div> 
        </template>
      </el-table-column>

      <el-table-column  label="订单日期"> 
        <template slot-scope="scope">
          <div>
            <p v-for="(item,index) in scope.row" :key="index">
              <span v-if="item.field_name=='订单日期'">{{item.value}}</span>
            </p>
          </div> 
        </template>
      </el-table-column>

      <el-table-column  label="交货日期"> 
        <template slot-scope="scope">
          <div>
            <p v-for="(item,index) in scope.row" :key="index">
              <span v-if="item.field_name=='交货日期'">{{item.value}}</span>
            </p>
          </div> 
        </template>
      </el-table-column>

      <el-table-column  label="订单备注"> 
        <template slot-scope="scope">
          <div>
            <p v-for="(item,index) in scope.row" :key="index">
              <span v-if="item.field_name=='订单备注'">{{item.value}}</span>
            </p>
          </div> 
        </template>
      </el-table-column>
      <el-table-column  label="操作"> 
        <template slot-scope="scope">
          <el-popconfirm
                confirm-button-text="确定"
                cancel-button-text="取消"
                icon="el-icon-info"
                icon-color="red"
                title="确定删除此数据吗？"
                @confirm="del_Order(scope.row.order_print_id)"
              >
                <el-button slot="reference" type="text">删除</el-button>
              </el-popconfirm> 
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <!-- <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        background
        @prev-click="prev"
        @next-click="next"
        :current-page.sync="pagination.page"
        :page-size="pagination.per_page"
        layout="total, prev, pager, next"
        :total="total"
      >
      </el-pagination> -->
    </div>
  </div>
</template>
<script>
import {getOrderPrintList,delOrderPrint} from "@/api/product/index";
export default {

  data() {
    return {
      loading: true,
      dayinlist:[],
      ser: {
        model_number_id: "",
        order_number: "",
        customer_id: "",
        product_id: "",
        order_date: "",
        is_replenishment: "",
        is_stock_up: "",
        start_time: "",
        end_time: "",
      },
      ChildList: [],
      pagination: {
        per_page: 10,
        page: 1,
      },
      total: 0,
    };
  },
  mounted() {
    this.childList();
  },
  methods: {
    del_Order(id){
      console.log(id)
      delOrderPrint({order_print_id:id}).then(res=>{
        if(res.code==200){
          this.$message({
            type: "success",
            message: "操作成功",
          });
          this.childList();
        }
      })
    },
    handleSelectionChang(val) {
      console.log(val);
      this.dayinlist = val;
    },
    childList(){
      getOrderPrintList({...this.pagination}).then(res=>{
          if(res.code==200){
              this.ChildList=res.data
              this.loading=false
          }
      })
    },
     //打印出货单
     print() {
      if (this.dayinlist.length > 0) {
        const routerurl = this.$router.resolve({
          name: "gddayin",
          path: "/gddayin",
          query: {
            data: JSON.stringify(this.dayinlist),
          },
        });
        window.open(routerurl.href, "_blank");
      } else {
        this.$message({
          type: "error",
          message: "请勾选数据",
        });
        return false;
      }
    },
  },
};
</script>
<style>
.my-label {
  background: #e1f3d8;
}

/* .my-content {
      background: #dd7575;
      color: #fff;
    } */

.ul {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 10px;
}

.li {
  width: 32.5%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  box-sizing: border-box;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  -ms-box-sizing: border-box;
  -o-box-sizing: border-box;
  overflow: hidden;
  margin-top: 16px;
  margin-left: 1.02%;
}

.li:nth-child(3n-2) {
  margin-left: 0;
}

.uls {
  width: 100%;
  max-width: 100%;
  overflow-x: scroll;
  white-space: nowrap;
}

.uls .lis {
  display: inline-block;
  margin-left: 0px;
  margin-top: 10px;
  padding: 5px;
  box-sizing: border-box;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  -ms-box-sizing: border-box;
  -o-box-sizing: border-box;
  border: 1px solid #fff;
  border-radius: 5px;
}

.uls .lis span {
  display: block;
  font-size: 14px;
  width: 100%;
  text-align: center;
  cursor: pointer;
  line-height: 16px;
}

.uls .lis span:nth-child(2) {
  /* margin-top: px; */
}

.wancheng {
  background: #1aa034;
  color: #fff;
}

.unwancheng {
  background: #1b8bf5;
  color: #fff;
}

.unpush {
  background: #ff6561;
  color: #fff;
}
.unwanchengs {
  background: #902c90;
  color: #fff;
}
/* .el-descriptions .is-bordered .el-descriptions-item__cell{
    padding: 5px!important;
  } */

.lable_width {
  width: 100px;
}

.el-table .el-table__cell {
  padding: 5px 0 !important;
}
</style>
